<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script src="wajax.js"></script>
<script>
   // demo1
   /*wajax({
       url:'./README.md',
       method:"get"
   }).then(res=>{
       console.log(res)
   }).catch(error=>{
       console.log(error)
   })*/

   // demo2
   /*wajax.defaults.withCredentials = true
   wajax.defaults.headers = {
       'siteId':0
   }
   wajax.defaults.timeout = 3000
   wajax.get('./README.md').then(res=>{
       console.log(res)
   })*/

   // demo 3
   // ajax.defaults.responseType = 'json';
   /*wajax.defaults.transformRequest((data)=>{
       return JSON.stringify(data)
   })
   wajax.interceptors.response(function (response) {
      return response.config.data
   },function (error) {
      return Promise.reject('请求错误')
   })
   wajax.post('./README1.md',{
       name:'wm',
       age:"22"
   }).then(res=>{
       console.log(res)
   }).catch(error=>{
       console.log(error)
   })*/
</script>
</body>
</html>
